<!--
 * @Description: 天气预报设置
 * @version: 电子名片2.0
 * @Author: 付小清
 * @Date: 2020-11-23 10:23:52
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-04-13 19:07:37
-->

<template>
  <div class="form-box" style="width: 60%">
    <columnInputList :columList="columList" @openMessage="openMessage" />
    <maeesge-box ref="box" @submit="submit" :title="messageInfo.title">
      <edit-form :editList="[edit]" />
    </maeesge-box>
  </div>
</template>

<script>
// 接口
// import { userSet } from '@/api/basics'
import maeesgeBox  from '@/components/admin/maeesge-box';
import editForm  from '@/components/admin/edit-form';
import columnInputList from './components/column-input-list.vue';
function createMessage(title, input, id) {
  return {
    title: title || '',
    input: input || '',
    id: id || ''
  }
}
function createBtns() {
  return [{title: 'API KEY', params: 'API KEY'},{title: 'SECRET KEY', params: 'SECRET KEY'}];
} 
function createColumList() {
  const columList = [
    {
      name: '天气平台', 
      columChild: [{label: '天气预报平台网址：', value: '', btn: createBtns()}]
    },
    {
      name: '审核平台', 
      columChild: [
        {label: '文字审核平台：', value: '', tip: '支持百度', btn: createBtns()},
        {label: '图片审核平台：', value: '', tip: '支持百度', btn: createBtns()},
        {label: '语音审核平台：', value: '', tip: '支持百度', btn: createBtns()},
        {label: '视频审核平台：', value: '', tip: '支持百度', btn: createBtns()}
      ]
    },
    {
      name: '识别平台', 
      columChild: [
        {label: '语音识别平台：', value: '', tip: '支持百度', btn: createBtns()},
        {label: '人脸识别平台：', value: '', tip: '支持百度', btn: createBtns()}
      ]
    }
  ];
  return columList;
}
export default {
  data() {
    return {
      columList: createColumList(),
      title: '',
      messageInfo: createMessage(),
      edit: { }
    }
  },
  components: {
    columnInputList,
    editForm,
    maeesgeBox
  },
  methods: {
    submit() {
      this.$refs.box.close();
    },
    openMessage(title) {
      this.messageInfo = createMessage(title);
      this.edit = { type: 'input', key: title, label: title+'：',  placeholder: '请输入' },
      this.$refs.box.open();
    }, 
  },
  computed: {
    size() {
      return this.$store.getters.size
    }
  }
}
</script>

<style lang="scss" scoped>
  
</style>
